]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Disable the tray dwell when the user is interacting
authorOwen W. Taylor <otaylor@fishsoup.net>
Thu, 6 Sep 2012 16:02:26 +0000 (12:02 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Fri, 14 Sep 2012 14:42:40 +0000 (10:42 -0400)
Look at the focus window's interaction timestamp to catch the case
where the user is typing and knocks the pointer into the tray or
mouses down to the bottom of the screen and clicks on something.
If the focus window's interaction time differs at the start and
end of the tray dwell then we don't activate the tray.

https://bugzilla.gnome.org/show_bug.cgi?id=683811

js/ui/messageTray.js

index c563b8fc5c4c0d7753502fd06cf7e0585eb1117f..1b6409871ecb01f76edf871bb8bfffdfa759fa98 100644 (file)
@@ -1510,6 +1510,7 @@ const MessageTray = new Lang.Class({
         pointerWatcher.addWatch(TRAY_DWELL_CHECK_INTERVAL, Lang.bind(this, this._checkTrayDwell));
         this._trayDwellTimeoutId = 0;
         this._trayDwelling = false;
+        this._trayDwellUserTime = 0;
     },
 
     _checkTrayDwell: function(x, y) {
@@ -1523,9 +1524,14 @@ const MessageTray = new Lang.Class({
             // of the monitor. The _trayDwelling variable is used so that we only try to
             // fire off one tray dwell - if it fails (because, say, the user has the mouse down),
             // we don't try again until the user moves the mouse up and down again.
-            if (!this._trayDwelling && !this.actor.hover && this._trayDwellTimeoutId == 0)
+            if (!this._trayDwelling && !this.actor.hover && this._trayDwellTimeoutId == 0) {
+                // Save the interaction timestamp so we can detect user input
+                let focusWindow = global.display.focus_window;
+                this._trayDwellUserTime = focusWindow ? focusWindow.user_time : 0;
+
                 this._trayDwellTimeoutId = Mainloop.timeout_add(TRAY_DWELL_TIME,
                                                                 Lang.bind(this, this._trayDwellTimeout));
+            }
             this._trayDwelling = true;
         } else {
             this._cancelTrayDwell();
@@ -1541,6 +1547,13 @@ const MessageTray = new Lang.Class({
     },
 
     _trayDwellTimeout: function() {
+        // If the user interacted with the focus window since we started the tray
+        // dwell (by clicking or typing), don't activate the message tray
+        let focusWindow = global.display.focus_window;
+        let currentUserTime = focusWindow ? focusWindow.user_time : 0;
+        if (currentUserTime != this._trayDwellUserTime)
+            return false;
+
         this._trayDwellTimeoutId = 0;
 
         this._traySummoned = true;